﻿// <copyright file="Product.cs" company="Snowman Consulting">
//     Copyright (c) 2009 Snowman Consulting. All rights reserved.
// </copyright>

namespace SnowmanConsulting.ProductKeyManager.Data
{
    using System;
    using System.ComponentModel;
    using System.Windows.Media.Imaging;

    /// <summary>
    /// Product class
    /// </summary>
    public class Product : INotifyPropertyChanged
    {
        #region Fields

        /// <summary>
        /// product icon
        /// </summary>
        private ProductIcon icon;

        /// <summary>
        /// The name of this product
        /// </summary>
        private string name;

        /// <summary>
        /// The notes for this product
        /// </summary>
        private string notes;

        /// <summary>
        /// The keys for this product
        /// </summary>
        private ProductKeyCollection keys;

        /// <summary>
        /// The category for this product
        /// </summary>
        private string category;

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="Product"/> class.
        /// </summary>
        public Product()
        {
            this.keys = new ProductKeyCollection();
        }

        #endregion

        #region Events

        /// <summary>
        /// Occurs when a property value changes.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets the name.
        /// </summary>
        /// <value>The name of the product.</value>
        public string Name
        {
            get
            {
                return this.name;
            }

            set
            {
                if (this.name != value)
                {
                    this.name = value;
                    this.NotifyPropertyChanged("Name");
                }
            }
        }

        /// <summary>
        /// Gets or sets the notes.
        /// </summary>
        /// <value>The notes for this product.</value>
        public string Notes
        {
            get
            {
                return this.notes;
            }

            set
            {
                if (this.notes != value)
                {
                    this.notes = value;
                    this.NotifyPropertyChanged("Notes");
                }
            }
        }

        /// <summary>
        /// Gets or sets the icon.
        /// </summary>
        /// <value>The product icon.</value>
        public ProductIcon Icon
        {
            get
            {
                return this.icon;
            }

            set
            {
                if (this.icon != value)
                {
                    this.icon = value;
                    this.NotifyPropertyChanged("Icon");
                }
            }
        }

        /// <summary>
        /// Gets the keys.
        /// </summary>
        /// <value>The product keys.</value>
        public ProductKeyCollection Keys
        {
            get
            {
                return this.keys;
            }
        }

        /// <summary>
        /// Gets or sets the category.
        /// </summary>
        /// <value>The category for this product.</value>
        public string Category
        {
            get
            {
                return this.category;
            }

            set
            {
                if (this.category != value)
                {
                    this.category = value;
                    this.NotifyPropertyChanged("Category");
                }
            }
        }

        #endregion

        #region Methods

        /// <summary>
        /// Notifies the property changed.
        /// </summary>
        /// <param name="info">The name of the property changed</param>
        private void NotifyPropertyChanged(string info)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        #endregion
    }
}
